// split.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "split.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object

CWinApp theApp;

using namespace std;

int splitString(CString str, CString var, CStringArray &strs)
{
	int count = 0;

	CString tempStr = str;

	int length = str.GetLength();

	int splitNameLength = var.GetLength();

	while(length)
	{
		int find = tempStr.Find(var);
		if(find != -1)
		{
			CString temp  = tempStr.Left(find);
			strs.Add(temp);

			tempStr = tempStr.Mid(find + splitNameLength);
			count++;
		}
		else
		{
			strs.Add(tempStr);
			length = 0;
		}
	}


	return count;
}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		return 1;
	}

	CString temp = _T("parkasseaschul");

	CStringArray str;

	int count = splitString(temp, _T("as"),str);

	int size = str.GetSize();

	for(int i = 0 ; i < size ; i++)
	{
		::AfxMessageBox(str.GetAt(i));
	}


	int aa = 0;


	return 0;
}
